﻿// namespace DYH.CAD.Assoc;
//
// public static class AssocTool
// {
//     public static ErrorStatus CreateActionAndActionBodyAndPostToDatabase(RXClass actionBodyClass, ObjectId ownerId, out ObjectId actionId, out ObjectId actionBodyId)
//     {
//         actionId = actionBodyId = ObjectId.Null;
//         try
//         {
//             if (!actionBodyClass.IsDerivedFrom(RXObject.GetClass(typeof(AssocActionBody))) ||
//                 Activator.CreateInstance(actionBodyClass.GetRuntimeType()) is not AssocActionBody actionBody)
//                 return ErrorStatus.NotThatKindOfClass;
//             var db = ownerId.Database;
//             using var tr = new DBTrans(db);
//             var networkId = AssocNetwork.GetInstanceFromObject(ownerId, true, true, "");
//             var network = (AssocNetwork)tr.GetObject(networkId, OpenMode.ForWrite);
//             actionBodyId = db.AddDBObject(actionBody);
//             tr.Transaction.AddNewlyCreatedDBObject(actionBody, true);
//             using var action = new AssocAction();
//             action.ActionBody = actionBodyId;
//             actionId = db.AddDBObject(action);
//             network.AddAction(actionId, true);
//             return ErrorStatus.OK;
//         }
//         catch (AcException e)
//         {
//             return e.ErrorStatus;
//         }
//         catch (Exception)
//         {
//             return ErrorStatus.InternetUnknownError;
//         }
//     }
// }